public class Solution2232 {
    public String minimizeResult(String expression) {
        String[] strings=expression.split("\\+");
        long max= Long.MAX_VALUE;
        String ans="";
        for (int i=0;i<strings[0].length();i++){
            for (int j=1;j<=strings[1].length();j++){
                long m1=i==0?1:Long.parseLong(strings[0].substring(0,i));
                long m2=Long.parseLong(strings[0].substring(i))+Long.parseLong(strings[1].substring(0,j));
                long m3=j==strings[1].length()?1:Long.parseLong(strings[1].substring(j));
                if (m1*m2*m3<max){
                    max=m1*m2*m3;
                    StringBuilder stringBuilder=new StringBuilder();
                    for (int k=0;k<i;k++){
                        stringBuilder.append(strings[0].charAt(k));
                    }
                    stringBuilder.append('(');
                    for (int k=i;k<strings[0].length();k++){
                        stringBuilder.append(strings[0].charAt(k));
                    }
                    stringBuilder.append('+');
                    for (int k=0;k<j;k++){
                        stringBuilder.append(strings[1].charAt(k));
                    }
                    stringBuilder.append(')');
                    for (int k=j;k<strings[1].length();k++){
                        stringBuilder.append(strings[1].charAt(k));
                    }
                    ans=stringBuilder.toString();
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution2232().minimizeResult("247+38"));
    }
}
